<?php include_once 'brand_header_index.php' ;?>
<!--主体内容-->
<div class="main brand_favorites">

	<div id="topliclistItems">
		<?php foreach($myfav as $myfav){ $liuyan = $myfav['liuyan']; ?>
		<dl class="topic" style="margin:5px auto;">
        	<dt><a href="###"><img src="images/brand/<?php echo $myfav['pic']; ?>" class="imgh2" /></a></dt>
            <dd><a href="index.php?mod=brandindex&code=detail&ids=<?php echo $myfav['id'];?>"><b><?php echo $myfav['tobacco_name']; ?></b>: <?php echo $myfav['intro']; ?></a></dd>
			<?php //获取第一条评论
			if( !empty( $liuyan ) ){
				if( $liuyan['face'] == "" ){ $liuyan['face'] = "images/noavatar.gif" ;}//默认图像
echo <<<HERE
			<dd class="comment"><a href="index.php?mod={$liuyan['username']}">
			    <img align="left" class="com_img" src="{$liuyan['face']}" alt="{$liuyan['nickname']}" /> 
			    {$liuyan['nickname']}</a>：{$liuyan['content']}
			</dd>
HERE;
			} 
			?>
            <dd class="fav clear"><a onclick="recommend('<?php echo $myfav['uid'];?>','<?php echo $myfav['id'];?>');">推荐</a>
			<a href="javascript:void(0);" onclick="showComment('<?php echo $myfav['id'];?>')">评论</a><a onclick="delfav('<?php echo $myfav['uid'];?>','<?php echo $myfav['favid'];?>');">取消收藏</a></dd>
        </dl>
		<?php }?>
	</div>
</div>
<script type="text/javascript">

$(function(){

	  
	var $container = $('#topliclistItems');

	$container.imagesLoaded( function(){
	  $container.masonry({
        itemSelector : '.topic',
		columnWidth: function( containerWidth ) {
			return containerWidth / 4;
		}
	  });
	});
});


function recommend(uid,id){
	$.ajax({
		url: 'index.php?mod=brandindex&code=nav',
		data: 'uid='+uid+'&id='+id,
		success: function(d){
			art.dialog({
				title: '提示', 
				content: "<b class='notice'>"+d+"</b>",
				width: 180,fixed: true,time: 1000
			})		
		}	
	});
}
function delfav(uid,id){
	$.ajax({
		url: 'index.php?mod=brandindex&code=favorite',
		data: 'uid='+uid+'&favid='+id,
		success: function(d){
			art.dialog({
				title: '提示', 
				content: "<b class='notice'>"+d+"</b>",
				width: 180,fixed: true,time: 1000
			})		
		}	
	});
}

function showComment(tid){
	$("#artDialog-skin").attr("href","templates/app/skins/default.css");
	tmphtml = '	<form name="comt" id="comt" method="post" >';
	tmphtml += '<textarea class="comm_text" cols="" rows="5" id="content" name="content">发评论...</textarea>';
	tmphtml += '</form>';
	$("#div_comm").html(tmphtml);
	art.dialog({
		id: "dialog_show",
		title: '发评论：', 
		content: $("#div_comm").html(),
		padding: 5,fixed: true, lock:true,
		button: [
			{
				value: '留言评价',
				callback: function () {
					post_data = {
						'content': $("#content").val(),
						'userid': '<?php echo $_COOKIE['MEMBER_ID'];?>',
						'tobid': tid
					}
					this.close();
					pushcomment(post_data);
				},
				focus: true
			},
			{
				value: '关闭'
			}
		]
	});
}

function pushcomment(formParam){
	$.ajax({
		url: 'index.php?mod=brandindex&code=comment',
		type: 'POST',
		cache:false,
		dataType: 'html',
		data: formParam,
		success: function(d){
		    if(d==''){
			art.dialog({
				title: '提示', 
				content:'请输入留言信息',
				time: 1000
			})	
			}else if(d==1){
			$("#artDialog-skin").attr("href","templates/app/skins/simple.css");
			art.dialog({
				title: '提示', 
				content:'请先登录',
				time: 1000
			})	
			}
			else{
				$('#procomments').prepend(d);
				art.dialog({
					title: '提示', width: 160,
					content:'留言成功',
					time: 2000,
					cancelValue: '关闭',
					cancel: function (){
						location.reload();
					}
				});
			}	
		}
	})
}
</script>
<div id="div_comm" style="display:none;"></div>
<!--底部-->
<?php include_once 'brand_footer.php' ;?>
